<?php
/**
 *
 * Show the products in a category
 *
 * @package    VirtueMart
 * @subpackage
 * @author RolandD
 * @author Max Milbers
 * @todo add pagination
 * @link http://www.virtuemart.net
 * @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * VirtueMart is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * @version $Id: default.php 6556 2012-10-17 18:15:30Z kkmediaproduction $
 */

//vmdebug('$this->category',$this->category);
vmdebug ('$this->category ' . $this->category->category_name);
// Check to ensure this file is included in Joomla!
defined ('_JEXEC') or die('Restricted access');
JHtml::_('behavior.framework');
JHTML::_ ('behavior.modal');
/* javascript for list Slide
  Only here for the order list
  can be changed by the template maker
*/
$js = "
jQuery(document).ready(function () {
	jQuery('.orderlistcontainer').hover(
		function() { jQuery(this).find('.orderlist').stop().show()},
		function() { jQuery(this).find('.orderlist').stop().hide()}
	)
});
";

$document = JFactory::getDocument ();
$document->addScriptDeclaration ($js);





if (empty($this->keyword)) {
	?>
<div class="container-fluid" id="catDesc">
	<div class="row-fluid">
		<div class="span12">
		<h2><?php echo $this->category->category_name; ?></h2>
		
		
				    	<?php 
				
								require_once(JPATH_BASE.DS.'components'.DS.'com_brinkmanvm'.DS.'helpers'.DS.'brinkmanvm.php');
								echo $image = BrinkmanvmHelper::showImage(strtolower($this->category->metadesc),'img img-rounded imgcategory',false,true);
				
									    	
					    //	 echo $category->images[0]->displayMediaFull("class='img img-rounded bkmimgcat'",false); 
					    
					    ?>		
		
		
		<?php if($this->category->category_description!=''):?>
			<div class="well well-small"><?php echo $this->category->category_description; ?></div>
		<?php endif;?>
		

		
	</div>
</div>
<?php
}

/* Show child categories */

if (VmConfig::get ('showCategory', 1) and empty($this->keyword)) {
	if ($this->category->haschildren) {

		// Category and Columns Counter
		$iCol = 1;
		$iCategory = 1;

		// Calculating Categories Per Row
		$categories_per_row = VmConfig::get ('categories_per_row', 3);
		$category_cellwidth = ' width' . floor (100 / $categories_per_row);
		$bootstrapSpans = 12/$categories_per_row;
		?>

		<div class="container-fluid" id="bkm_categories">

		<?php // Start the Output
		if (!empty($this->category->children)) {
			foreach ($this->category->children as $category) {


				// this is an indicator wether a row needs to be opened or not
				if ($iCol == 1) {
					?>
			<div class="row-fluid">
			<?php
				}


				// Category Link
				$caturl = JRoute::_ ('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $category->virtuemart_category_id);

				// Show Category
				?>

				
				<div class="span<?php echo $bootstrapSpans;?>">
					<div class="bkmCatItem">
						<h3><a href="<?php echo $caturl ?>" title="<?php echo $category->category_name ?>"><?php echo $category->category_name ?></a></h3>
						<div class="bkm_cat_image">			
							<a href="<?php echo $caturl ?>" title="<?php echo $category->category_name ?>">
					    	<?php 
				
								require_once(JPATH_BASE.DS.'components'.DS.'com_brinkmanvm'.DS.'helpers'.DS.'brinkmanvm.php');
								echo $image = BrinkmanvmHelper::showImage(strtolower($category->metadesc),'img img-rounded');
				
									    	
					    //	 echo $category->images[0]->displayMediaFull("class='img img-rounded bkmimgcat'",false); 
					    
					    ?>
							</a>
						</div>
					</div>
					
				</div>
				
				
				
				<?php
				$iCategory++;

				// Do we need to close the current row now?
				if ($iCol == $categories_per_row) {
					?>
					<div class="clear"></div>
		</div>
			<?php
					$iCol = 1;
				} else {
					$iCol++;
				}
			}
		}
		// Do we need a final closing row tag?
		if ($iCol != 1) {
			?>
			<div class="clear"></div>
		</div>
	<?php } ?>
	</div>

	<?php
	}
}
?>
<div class="browse-view">
<?php
if (!empty($this->keyword)) {
	?>
<h3><?php echo $this->keyword; ?></h3>
	<?php
} ?>


<?php // Show child categories
if (!empty($this->products)) {
	?>


<div class="container-fluid">
	<?php
	// Category and Columns Counter
	$iBrowseCol = 1;
	$iBrowseProduct = 1;

	// Calculating Products Per Row
	$BrowseProducts_per_row = $this->perRow;
	$Browsecellwidth = ' width' . floor (100 / $BrowseProducts_per_row);
	$bootstrapSpans = 12/$BrowseProducts_per_row;
	// Separator
	$verticalseparator = " vertical-separator";

	$BrowseTotalProducts = count($this->products);

	// Start the Output
	foreach ($this->products as $product) {


		// this is an indicator wether a row needs to be opened or not
		if ($iBrowseCol == 1) {
			?>
	
	<div class="row-fluid">
	<?php
		}

		// Show the vertical seperator
		if ($iBrowseProduct == $BrowseProducts_per_row or $iBrowseProduct % $BrowseProducts_per_row == 0) {
			$show_vertical_separator = ' ';
		} else {
			$show_vertical_separator = $verticalseparator;
		}

		// Show Products
		?>
		<div class="span<?php echo $bootstrapSpans;?> bkmproduct">
			
			<div class="innerProduct">
				<div class="row-fluid">
					<div class="span12 catProdRight">
						<h3><?php echo JHTML::link ($product->link, $product->product_name); ?></h3>

					</div>
				</div>
				<div class="row-fluid">
					<div class="span12 catProdLeft">
						<a title="<?php echo $product->product_name ?>" rel="vm-additional-images" href="<?php echo $product->link; ?>">
							<?php
								require_once(JPATH_BASE.DS.'components'.DS.'com_brinkmanvm'.DS.'helpers'.DS.'brinkmanvm.php');
								echo $image = BrinkmanvmHelper::showImage(strtolower($product->product_sku),'img img-rounded');
								
							
							 ?>
						</a>
		
												
					</div>
	
				</div>
	
							
			</div>

		</div> <!-- end of product -->
		<?php

		// Do we need to close the current row now?
		if ($iBrowseCol == $BrowseProducts_per_row || $iBrowseProduct == $BrowseTotalProducts) {
			?>
			<div class="clear"></div>
   </div> <!-- end of row -->
			<?php
			$iBrowseCol = 1;
		} else {
			$iBrowseCol++;
		}

		$iBrowseProduct++;
	} // end of foreach ( $this->products as $product )
	// Do we need a final closing row tag?
	if ($iBrowseCol != 1) {
		?>
	<div class="clear"></div>

		<?php
	}
	?>
</div>
<div class="container-fluid">
	<div class="row-fluid">
		<div class="span12">
			<div class="pagination paginationBkm">
			<?php echo $this->vmPagination->getLimitBox (); ?>
			<?php echo $this->vmPagination->getPagesCounter (); ?>	<br>		
			<?php echo $this->vmPagination->getPagesLinks (); ?>

			
			</div>
			
		</div>

	</div>
</div>

	<?php
} elseif ($this->search !== NULL) {
	echo JText::_ ('COM_VIRTUEMART_NO_RESULT') . ($this->keyword ? ' : (' . $this->keyword . ')' : '');
}

?>
</div><!-- end browse-view -->
<?php
$search = JRequest::getVar('search',0);
if(!$search) echo "</div>";
?>


